<!DOCTYPE html>
<!--在html页面中引入thymeleaf命名空间，即，此时在html模板文件中动态的属性使用th:命名空间修饰 。-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="../static/layui-v2.6.13/layui/css/layui.css">
    <script type="text/javascript" src="../static/js/jquery.min-2.1.1.js"></script>
    <script type="text/javascript" src="../static/layui-v2.6.13/layui/layui.js"></script>
</head>
<body>
<div>
    <input type="text" placeholder="请输入id" id="id">
</div>
    <div>
        <input type="text" placeholder="请输入专业名" id="majorName">
    </div>
<div>
    <input type="text" placeholder="请输入学院id" id="collegeId">
</div>
<div>
    <input type="text" placeholder="请输入专业id" id="majorId">
</div>
<button type="submit" class="layui-btn layui-btn-radius layui-btn-primary" onclick="insert()">添加</button>
<script>
    function insert(){
        var id=$("#id").val();
        var majorName=$("#majorName").val();
        var collegeId=$("#collegeId").val();
        var majorId=$("#majorId").val();
        var params = "id="+id+"&majorName="+majorName+"&collegeId="+collegeId+"&majorId="+majorId;

        $.ajax({
            url:"insert",
            data:params,
            type:"post",
            success:function (str){
                if(str=="1"){
                    alert("添加成功");
                    parent.location.href="index";
                }else{
                    alert("添加失败");
                }

            }
        })
    }

</script>
</body>
</html>